java Solution
